class HuskGunNew extends KFWeapon;

var float FireCharge,FireChargeRegenRate;

replication
{
	reliable if ( Role == ROLE_Authority )
		FireCharge,
		HuskGunChargeBar;
}

function float GetAIRating()
{
	local AIController B;

	B = AIController(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return AIRating;

	return (AIRating + 0.0003 * FClamp(1500 - VSize(B.Enemy.Location - Instigator.Location),0,1000));
}

function byte BestMode()
{
	return 0;
}

function bool RecommendRangedAttack()
{
	return true;
}

//TODO: LONG ranged?
function bool RecommendLongRangedAttack()
{
	return true;
}

function float SuggestAttackStyle()
{
	return -1.0;
}

simulated function AnimEnd(int channel)
{
    if (FireMode[0].bIsFiring)
    {
    	if( bAimingRifle )
    	{
    		LoopAnim('ChargeLoop_Iron');
    	}
    	else
    	{
    		LoopAnim('ChargeLoop');
    	}
    }
    else
    {
        Super.AnimEnd(channel);
    }
}

simulated event OnZoomOutFinished()
{
	local name anim;
	local float frame, rate;

	GetAnimParams(0, anim, frame, rate);

	if (ClientState == WS_ReadyToFire)
	{
		// Play the regular idle anim when we're finished zooming out
		if (anim == IdleAimAnim)
		{
            PlayIdle();
		}
		else if(anim == 'ChargeLoop_Iron')
		{
            LoopAnim('ChargeLoop');
		}
	}
}

simulated event OnZoomInFinished()
{
	local name anim;
	local float frame, rate;

	GetAnimParams(0, anim, frame, rate);

	if (ClientState == WS_ReadyToFire)
	{
		// Play the iron idle anim when we're finished zooming in
		if (anim == IdleAnim)
		{
		   PlayIdle();
		}
		else if( anim == 'ChargeLoop' )
		{
            LoopAnim('ChargeLoop_Iron');
		}
	}
}

simulated function bool ConsumeAmmo( int Mode, float Load, optional bool bAmountNeededIsMax );
function GiveAmmo(int m, WeaponPickup WP, bool bJustSpawned);

simulated function Tick(float DT)
{
	local float CooldownMod;
	
	Super.Tick(DT);
	
	if ( SRPlayerReplicationInfo(Instigator.PlayerReplicationInfo).ClientVeteranSkill == class'SRVetFirebug' )
	{
		CooldownMod = 1.00;
	}
	else
	{
		CooldownMod = 0.40;
	}
	FireCharge = FMin(100.0,FireCharge + FireChargeRegenRate * CooldownMod * DT);
}

simulated function float HuskGunChargeBar()
{
	DKGameType(Level.Game).DebugMessage("FireCharge = " $ string(FireCharge));
	return (100.0 - FireCharge);
	
}

simulated function Overheat(float Value)
{
	FireCharge -= Value;
}

defaultproperties
{
	FireChargeRegenRate=3.75
	FireCharge=0.0
     MagCapacity=1
     ReloadRate=0.010000
     Weight=6.000000
     bHasAimingMode=True
     IdleAimAnim="Idle_Iron"
     StandardDisplayFOV=65.000000
     TraderInfoTexture=Texture'KillingFloor2HUD.Trader_Weapon_Icons.Trader_Huskgun'
     bIsTier3Weapon=True
     MeshRef="KF_Wep_HuskGun.HuskGun_Trip"
     SkinRefs(0)="KF_Weapons4_Trip_T.Weapons.HUSKGun_shdr"
     SelectSoundRef="KF_HuskGunSnd.Husk_Select"
     HudImageRef="KillingFloor2HUD.WeaponSelect.Huskgun_unselected"
     SelectedHudImageRef="KillingFloor2HUD.WeaponSelect.Huskgun"
     PlayerIronSightFOV=70.000000
     ZoomedDisplayFOV=45.000000
     FireModeClass(0)=Class'HuskGunNewFire'
     FireModeClass(1)=Class'KFMod.NoFire'
     PutDownAnim="PutDown"
     SelectForce="SwitchToAssaultRifle"
     AIRating=0.650000
     CurrentRating=0.650000
     Description="A fireball cannon ripped from the arm of a dead Husk. Does more damage when charged up."
     DisplayFOV=65.000000
     Priority=135
     InventoryGroup=4
     GroupOffset=7
     PickupClass=Class'HuskGunNewPickup'
     PlayerViewOffset=(X=18.000000,Y=20.000000,Z=-6.000000)
     BobDamping=6.000000
     AttachmentClass=Class'KFMod.HuskGunAttachment'
     IconCoords=(X1=253,Y1=146,X2=333,Y2=181)
     ItemName="Husk Fireball Launcher"
     LightType=LT_None
     LightBrightness=0.000000
     LightRadius=0.000000
}
